package com.chaofan.messagebook.bean;

import cn.hutool.json.JSONUtil;
import lombok.Builder;
import lombok.Data;

import java.util.List;

/**
 * @author 李超凡
 * @since 2022/4/3 22:51
 */
@Data
@Builder
public class R {
    private Integer code;
    private Boolean success;
    private String message;
    private Object data;
    public static String success() {
        return JSONUtil.toJsonStr(R.builder().code(1).success(true).message("success").build());
    }
    public static String success(String message) {
        return JSONUtil.toJsonStr(R.builder().code(1).success(true).message(message).build());
    }
    public static String success(String message, Object data) {
        return JSONUtil.toJsonStr(R.builder().code(1).success(true).message(message).data(data).build());
    }
    public static String fail() {
        return JSONUtil.toJsonStr(R.builder().code(0).success(false).build());
    }
    public static String fail(String message) {
        return JSONUtil.toJsonStr(R.builder().code(0).success(false).message(message).build());
    }

}
